import request from '@/utils/request'
import { API_CONFIG } from '@/api/config'

// 查询商品分类列表
export function listCategory(query) {
  const params = {
    ...query,
    orgId: API_CONFIG.ORG_ID
  }
  return request({
    url: '/fun/category/list',
    method: 'get',
    params: params
  })
}

// 查询商品分类详细
export function getCategory(categoryId) {
  return request({
    url: '/mobile/product/categoryDetail/' + categoryId,
    method: 'get',
    params: {
      orgId: API_CONFIG.ORG_ID
    }
  })
}

// 移动端商品分类接口
// 查询所有商品分类列表（移动端）
export function listMobileCategory(query) {
  const params = {
    ...query,
    orgId: API_CONFIG.ORG_ID
  }
  return request({
    url: '/fun/mobile/category/list',
    method: 'get',
    params: params
  })
}

// 移动端查询树形商品分类列表
export function getCategoryTreeList(query) {
  const params = {
    ...query,
    orgId: API_CONFIG.ORG_ID
  }
  return request({
    url: '/mobile/category/tree',
    method: 'get',
    params: params
  })
}

// 兼容旧的函数名
export function listMobileCategoryTree(query) {
  return getCategoryTreeList(query)
}